﻿using Didsoft.Reporting.Utils;
using Microsoft.Reporting.WebForms;
using SIOGDE.Negocios.Servicios;
using SIOGDE.Reportes.Negocios;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Didsoft.Reporting.Builders.Microsoft;

namespace SIOGDE.Reportes
{
    [LayoutReport("SIOGDE.Reportes.Layout.FilePersona.rdlc")]
    public class FilePersonal : ReportRenderator
    {
        public FilePersonal()
        {
            LocalReport.ReportEmbeddedResource = "SIOGDE.Reportes.Layout.FilePersona.rdlc";
            //System.Security.PermissionSet permissions = new System.Security.PermissionSet(System.Security.Permissions.PermissionState.Unrestricted);
            //LocalReport.SetBasePermissionsForSandboxAppDomain(permissions);
        }

        public override void PrepareReport()
        {
            var business = BusinessFactory.Current.GetPersonaNegocios();
                        
            var filePersonalNegocios = new FilePersonalNegocios();
            var datos = filePersonalNegocios.GetPersonalInfo(Parameters);
            var destinos = filePersonalNegocios.GetHistorialDestinos(Parameters);
            
            ReportParameter parameter = new ReportParameter("Usuario", SIOGDE.Negocios.Global.Session.UserInfo.Nombre);            
            LocalReport.SetParameters(parameter);

            LocalReport.DataSources.Add(new ReportDataSource("DSPersona", datos));
            LocalReport.DataSources.Add(new ReportDataSource("DSDestinos", destinos));
        }

    }

}
